package com.meizi.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Administration
 * @date 2021/8/9 - 14:33 - 星期一
 * @project lambda
 * @package com.meizi.enums
 * @by GGbomd猪猪侠
 */
public enum ErrorCodeEnum {
    INTERNAL_SERVER_ERROR(500, "未知错误"),
    UNAUTHORIZED(401, "未经授权"),
    FORBIDDEN(403, "被禁止的操作"),
    NOT_NULL(10001, "%s不能为空"),
    DB_RECORD_EXISTS(10002, "数据库记录已存在"),
    PARAMS_GET_ERROR(10003, "参数错误"),
    PARAMS_RESOLUTION_FAILED(10004, "参数解析失败"),
    ACCOUNT_PASSWORD_ERROR(10005, "帐户密码错误"),
    ACCOUNT_DISABLE(10006, "帐户已停用"),
    IDENTIFIER_NOT_NULL(10007, "标识符非空"),
    CAPTCHA_ERROR(10008, "验证码错误"),
    PASSWORD_ERROR(10009, "密码错误"),
    ACCOUNT_NOT_EXIST(10010, "用户不存在"),
    DATA_NOT_EXIST(10011, "未查询到数据"),
    DATA_SCOPE_PARAMS_ERROR(10013, "数据范围参数错误"),
    OSS_UPLOAD_FILE_ERROR(10014, "上传文件失败"),
    TOKEN_NOT_EMPTY(10015, "token不能为空"),
    TOKEN_INVALID(10017, "token已失效"),
    ACCOUNT_LOCK(10018, "用户被锁定"),
    TYPE_FORMAT_ERROR(10020, "类型转换错误"),
    SEND_SMS_ERROR(10021, "发送短信失败"),
    REDIS_ERROR(10022, "redis错误"),
    JSON_FORMAT_ERROR(10023, "JSON格式错误"),
    MAIL_TEMPLATE_NOT_EXISTS(10024, "邮件模板不存在"),
    UPLOAD_FILE_EMPTY(10025, "上传的文件为空"),
    INVALID_SYMBOL(10029, "无效的非法字符"),
    RETURN_MULTIPLE_DATA_ERRORS(10030, "返回多条数据错误"),
    ROLLBACK_MESSAGE(10036, "回滚消息"),
    END_PROCESS_PARALLEL_ERROR(10043, "多实例任务无法终止"),
    BACK_PROCESS_HANDLEING_ERROR(10047, "有多个并行任务无法回滚"),
    PARAMS_VERIFICATION_FAILED(11000, "参数验证失败"),
    DATA_TRANSMISSION_PARSING_ERROR(11100, "数据传输解析错误"),
    METHOD_PARAMS_TYPE_MISMATCH(12000, "方法参数类型不匹配"),
    SERVICE_CALL_ERROR(13000, "服务调用错误"),
    FIELD_IS_MISSING(20000, "sql语句异常");

    private int key;
    private String value;

    private ErrorCodeEnum(int key, String value) {
        this.value = value;
        this.key = key;
    }

    public static List<Map<Integer, String>> queryAll() {
        List<Map<Integer, String>> list = new ArrayList();
        ErrorCodeEnum[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            ErrorCodeEnum t = var1[var3];
            Map<Integer, String> tempMap = new HashMap();
            tempMap.put(t.getKey(), t.getValue());
            list.add(tempMap);
        }

        return list;
    }

    public static String queryValueByKey(int key) {
        ErrorCodeEnum[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            ErrorCodeEnum t = var1[var3];
            if (t.getKey() == key) {
                return t.getValue();
            }
        }

        return "";
    }

    public static boolean contains(int key) {
        ErrorCodeEnum[] values = values();
        ErrorCodeEnum[] var2 = values;
        int var3 = values.length;

        for(int var4 = 0; var4 < var3; ++var4) {
            ErrorCodeEnum e = var2[var4];
            if (e.getKey() == key) {
                return true;
            }
        }

        return false;
    }

    public int getKey() {
        return this.key;
    }

    public void setKey(final int key) {
        this.key = key;
    }

    public String getValue() {
        return this.value;
    }

    public void setValue(final String value) {
        this.value = value;
    }
}
